<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Navigation_model extends MY_Model
{

    public function __construct() {
        parent::__construct();
    }

    public function getAll()
    {
        return $this->db->get('menus')
                ->result();
    }

    public function get($id)
    {
        return $this->db->where('id', $id)
                ->get('menus')
                ->row();
    }

    public function update($id, $data)
    {
        return $this->db->where('id', $id)
                ->set($data)
                ->update('menus');
    }

    public function getMenuItemsFor($menu_id)
    {
        return $this->db->where('menu_id', $menu_id)
                ->order_by('orderno')
                ->get('menuitems')
                ->result();
    }

    public function get_menu_by_name($menu_name, $lang)
    {
        return $this->db->select('menuitems.*')
                ->where('menus.name', $menu_name)
                ->where('menus.lang', $lang)
                ->join('menus', 'menus.id = menuitems.menu_id')
                ->order_by('orderno')
                ->get('menuitems')
                ->result();
    }

}

/* End of file navigation_model.php */
/* Location: ./application/navigation_model.php */